//
//  HeadlinesCell.swift
//  OverseasOnlineShopping
//
//  Created by 唐先才 on 16/3/9.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import UIKit

class HeadlinesCell: UITableViewCell {

    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var timeLab: UILabel!
    @IBOutlet weak var titleLab: UILabel!
    @IBOutlet weak var priceLab: UILabel!
    @IBOutlet weak var praiseLab: UILabel!
    @IBOutlet weak var commentLab: UILabel!
    
    var model: TxcModel? {
        didSet {
            guard let model = model else {
                print("model")
                return
            }
            iconView.sd_setImageWithURL(NSURL(string: model.MainImage))
            timeLab.text = model.InfoTime
            titleLab.text = model.InfoTitle
            priceLab.text = model.CommodityPrice
            praiseLab.text = "\(model.IsGood)"
            commentLab.text = "\(model.InfoReview)"
        }
    }
    
    class func headlinesCellWith(tableView: UITableView, indexPath: NSIndexPath, dataArray: NSMutableArray) ->UITableViewCell {
        if let headlinesCell = tableView.dequeueReusableCellWithIdentifier("headlinesCell") as? HeadlinesCell {
            if dataArray.count > 0 {
                if let data = dataArray[indexPath.row] as? TxcModel {
                    headlinesCell.model = data
                }
            }
            return headlinesCell
        }
        return UITableViewCell()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
